<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>>ajax简单封装</title>
</head>
<body>
    <ul>
        
    </ul>
    <script src="./ajax.js"></script>
    <script>
        ajax('http://localhost:8181/prodcuts/A?price=21').then(
          value => {
              console.log(value)
              const lis = value.reduce((pre,p)=> pre + `<li>${p.id}--${p.name}--${p.price}</li>`,'')
              const ul = document.querySelector('ul')
              ul.innerHTML = lis
          },
          error =>{
              alert(error.message)
          }  
        )
    </script>
</body>
</html>